package com.fujica.db_operation.server.impl;

import com.fujica.db_operation.entity.Student;
import com.fujica.db_operation.mapper.IStudentMapper;
import com.fujica.db_operation.request.StudentReq;
import com.fujica.db_operation.server.IStudentService;
import com.google.common.collect.Maps;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;
import static com.fujica.db_operation.help.Helper.*;

/**
 * @ClassName StudentService
 * @Description TODO
 * @Author admin
 * @Date 2020/6/18 15:25
 * @Version 1.0
 **/

@Service
public class StudentServiceImpl implements IStudentService {

    @Autowired()
    private IStudentMapper iStudentMapper;

    @Override
    public List<Student> list(StudentReq req) {
        String genderStr = req.getGender();
        // 前端接受的参数为字符串，转化为数据库匹配的genderValue
        Integer gender = genderMap.get(genderStr);
        Map map = Maps.newHashMap();
        map.put("sno", req.getSno());
        map.put("sname", req.getSname());
        map.put("startAge", req.getStartAge());
        map.put("endAge", req.getEndAge());
        map.put("gender", gender);
        return iStudentMapper.list(map);
    }
}
